package GestioneDB;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class ConnessioneDB {
	
	static Connection myCon=null;
	static String driver= "org.postgresql.Driver";
	static String url = "jdbc:postgresql://localhost:5432/DbInfo3";
	static String username = "postgres";
	static String password = "admin";
	static String myDataField ="";
	static PreparedStatement myPS = null;
	static ResultSet myRS = null;
	
	
	public void StartConnection() throws ClassNotFoundException, SQLException{
	Class.forName(driver);
	myCon = DriverManager.getConnection(url,username,password);
	}
	
	public ResultSet ResultQuery(String s) throws SQLException{
		myPS = myCon.prepareStatement(s);
		myRS = myPS.executeQuery();
		return myRS;
	}
	
	public void Close() throws SQLException{
		myPS.close();
	}
	
	public ConnessioneDB() {
	}
}
